const globalIp = getApp().globalData.userIp
Page({

  /**
   * 页面的初始数据
   */
  data: {
    oneType: '0',
    twoType: '0',
    threeType: '0',
    fourType: '0',
    fiveType: '0',
    sixType: '0',
    sevenType: '0',
    dataColor: false,
    dataTime:"日期选择",
    dataTime1:"起始日期",
    dataTime2:"截止日期",
    dataFlag: false, //控制综合下拉框是否显示
  },

  dataShow: function () {//日期下拉
    if (this.data.dataFlag){
      this.setData({
        dataFlag : !this.data.dataFlag,
        screenFlag: false,
        screenColor: false
      })
    }else{
      this.setData({
        dataFlag: !this.data.dataFlag,
        screenFlag: false,
        screenColor: false
      })
    }
  },
  changeDate1(e) {
    this.setData({
      dataTime1: e.detail.value,
      // dataFlag: false,
      dataColor: true
    })
  },
  changeDate2(e) {
    this.setData({
      dataTime2: e.detail.value,
      dataFlag: false,
      dataColor: true
    })
    this.getManage()
  },

  gridBtn(e) {
    console.log(e.currentTarget.dataset.num)
  },

  getManage: function() {
    let that = this;
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    wx.request({
      url: globalIp + 'home/ordr/showWetQtySection',
      data: {
        openId: wx.getStorageSync('userInfo').openid,
        sdate: that.data.dataTime1 == '起始日期' ? '' : that.data.dataTime1,
        edate: that.data.dataTime2 == '截止日期' ? '' : that.data.dataTime2,
        login: wx.getStorageSync('userInfo').login || 'N'
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'POST',
      success: function(res) {
        if (res.data.jsonObject) {
          var data = res.data.jsonObject.data;
          that.setData({
            oneType: data[0].oneType,
            twoType: data[0].twoType,
            threeType: data[0].threeType,
            fourType: data[0].fourType,
            fiveType: data[0].fiveType,
            sixType: data[0].sixType,
            sevenType: data[0].sevenType
          })
        }
      },
      fail: function(res) {
        wx.showToast({
          title: '请返回上一页面，重新请求',
          icon: 'none',
          duration: 2000,
        })
      },
      complete: function(res) {
        wx.hideLoading()
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getManage()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    
  },
})